package com.xxx.system.auth;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

@Component
public class InitSystemListener implements ServletContextListener {

    @Autowired
    private PermissionScan permissionScan;

    //这个方法会在项目启动时自动执行
    @Override
    public void contextInitialized(ServletContextEvent sce) {
        //这个操作可能需要时间很长 甚至报错 影响项目的启动 所以单开一个线程来扫描
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                //执行扫描方法 将自定义注解的信息存到数据库
//                permissionScan.scanPermission();
            }
        });
        thread.start();

    }
}
